﻿using System.IO;
using System.Text;

namespace Latin_Vocabulary_Indicator
{
    public class fileOperator
    {
      public static bool totalQuit = false;
        public static string textInput (string path)
        {
            StreamReader sr = new StreamReader(path, Encoding.Default);
            string temp = sr.ReadToEnd();
            sr.Close();
            return temp;
        }
        public static void textOutput(string path, string text)
        {
            FileStream fs = new FileStream(path, FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);
            sw.Write(text);
            sw.Flush();
            sw.Close();
            fs.Close();
        }
        public static char toUpper(char input)
        {
            if (input >= 97 && input <= 122) return (char)(input - 32);
            else if (input == 'ā') return 'Ā';
            else if (input == 'ō') return 'Ō';
            else if (input == 'ī') return 'Ī';
            else if (input == 'ē') return 'Ē';
            else if (input == 'ū') return 'Ū';
            else return input;
        }
        public static char toLower(char input)
        {
            if (input >= 65 && input <= 90) return (char)(input + 32);
            else if (input == 'Ā') return 'ā';
            else if (input == 'Ō') return 'ō';
            else if (input == 'Ī') return 'ī';
            else if (input == 'Ē') return 'ē';
            else if (input == 'Ū') return 'ū';
            else return input;
        }
        public static char toggleAccent(char input)
        {
            if (input == 'A') return 'Ā';
            else if (input == 'O') return 'Ō';
            else if (input == 'I') return 'Ī';
            else if (input == 'E') return 'Ē';
            else if (input == 'U') return 'Ū';

            else if (input == 'a') return 'ā';
            else if (input == 'o') return 'ō';
            else if (input == 'i') return 'ī';
            else if (input == 'e') return 'ē';
            else if (input == 'u') return 'ū';

            else if (input == 'Ā') return 'A';
            else if (input == 'Ō') return 'O';
            else if (input == 'Ī') return 'I';
            else if (input == 'Ē') return 'E';
            else if (input == 'Ū') return 'U';

            else if (input == 'ā') return 'a';
            else if (input == 'ō') return 'o';
            else if (input == 'ī') return 'i';
            else if (input == 'ē') return 'e';
            else if (input == 'ū') return 'u';

            else return input;
        }
        public static string togglePos(string input)
        {
            if (input == "Masculine") return "m.";
            else if (input == "Feminine") return "f.";
            else if (input == "Neuter") return "n.";
            else if (input == "Adjective") return "adj.";
            else if (input == "Adverb") return "adv.";
            else if (input == "Pronoun") return "pron.";
            else if (input == "Preposition") return "prep.";
            else if (input == "Conjunction") return "conj.";
            else if (input == "Interjection") return "int.";
            else if (input == "Verb") return "v.";
            else if (input == "Multigender") return "two.";
            else if (input == "Interrogation") return "r.";

            else if (input == "m.") return "Masculine";
            else if (input == "f.") return "Feminine";
            else if (input == "n.") return "Neuter";
            else if (input == "adj.") return "Adjective";
            else if (input == "adv.") return "Adverb";
            else if (input == "pron.") return "Pronoun";
            else if (input == "prep.") return "Preposition";
            else if (input == "conj.") return "Conjunction";
            else if (input == "int.") return "Interjection";
            else if (input == "v.") return "Verb";
            else if (input == "two.") return "Multigender";
            else if (input == "r.") return "Interrogation";

            else if (input == "\\") return "\\";

            else return null;
        }
        public static string accentTransform(string source, bool toRealAccent)
        {
            if (toRealAccent) return source.Replace("a`", "ā").Replace("o`", "ō").Replace("i`", "ī").Replace("e`", "ē").Replace("u`", "ū").Replace("A`", "Ā").Replace("O`", "Ō").Replace("I`", "Ī").Replace("E`", "Ē").Replace("U`", "Ū");
            else return source.Replace("ā", "a`").Replace("ō", "o`").Replace("ī", "i`").Replace("ē", "e`").Replace("ū", "u`").Replace("Ā", "A`").Replace("Ō", "O`").Replace("Ī", "I`").Replace("Ē", "E`").Replace("Ū", "U`");
        }

    }
}
